<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:0px;border:0px">
  <t:datagrid name="tMmPrList" checkbox="true" pagination="true" fitColumns="true" title="采购申请" actionUrl="tMmPrController.do?datagrid" idField="id" fit="false" queryMode="group">
   <t:dgCol title="主键"  field="id"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="创建人名称"  field="createName"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="创建人登录名称"  field="createBy"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="创建日期"  field="createDate"  formatter="yyyy-MM-dd"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="更新人名称"  field="updateName"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="更新人登录名称"  field="updateBy"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="更新日期"  field="updateDate"  formatter="yyyy-MM-dd"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="所属部门"  field="sysOrgCode"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="所属公司"  field="sysCompanyCode"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="流程状态"  field="bpmStatus"  hidden="true"  queryMode="single"  dictionary="bpm_status"  width="120"></t:dgCol>
   <t:dgCol title="采购申请号"  field="docnum"  query="true"  queryMode="group"  width="120"></t:dgCol>
   <t:dgCol title="商品编码"  field="matcode"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="商品名称"  field="matname"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="数量"  field="quantity"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="单位"  field="unit"  queryMode="single"  dictionary="t_sys_unit,unit,unit"  width="120"></t:dgCol>
   <t:dgCol title="交货日期"  field="deliverydate"  formatter="yyyy-MM-dd"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="供应商"  field="vendorcode"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="供应商名称"  field="vendorname"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="文本"  field="text"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="操作" field="opt" width="100"></t:dgCol>
   <t:dgDelOpt title="删除" url="tMmPrController.do?doDel&id={id}" urlclass="ace_button"  urlfont="fa-trash-o"/>
   <t:dgToolBar title="录入" icon="icon-add" url="tMmPrController.do?goAdd" funname="add"></t:dgToolBar>
   <t:dgToolBar title="编辑" icon="icon-edit" url="tMmPrController.do?goUpdate" funname="update"></t:dgToolBar>
   <t:dgToolBar title="分配供应商"  funname="pcALLSelect"></t:dgToolBar>
   <t:dgToolBar title="转采购订单"  funname="zdALLSelect"></t:dgToolBar>

   <t:dgToolBar title="批量删除"  icon="icon-remove" url="tMmPrController.do?doBatchDel" funname="deleteALLSelect"></t:dgToolBar>
   <t:dgToolBar title="查看" icon="icon-search" url="tMmPrController.do?goUpdate" funname="detail"></t:dgToolBar>
   <%--<t:dgToolBar title="导入" icon="icon-put" funname="ImportXls"></t:dgToolBar>--%>
   <%--<t:dgToolBar title="导出" icon="icon-putout" funname="ExportXls"></t:dgToolBar>--%>
   <%--<t:dgToolBar title="模板下载" icon="icon-putout" funname="ExportXlsByT"></t:dgToolBar>--%>
  </t:datagrid>
   <div name="searchColums1" style="float: left; padding-left: -100px;padding-top: 5px;">
    <span style="vertical-align:middle;display:-moz-inline-box;display:inline-block;width: 90px;text-align:right;" title="供应商">供应商 </span>

    <t:dictSelect id="vendorcode" field="vendorcode" defaultVal="请选择" dictTable="t_md_vendor"   dictField="vendorcode" dictText="vendorname" title="供应商"></t:dictSelect>
   </div>
  </div>
 </div>
 <script src = "webpage/com/erp/mm/tMmPrList.js"></script>
 <script type="text/javascript">
 $(document).ready(function(){
 });
 
   function pcALLSelect() {
       var count=$("#vendorcode option").length;
       var vendorcode;
       for(var i=0;i<count;i++)
       {
           if($("#vendorcode ").get(0).options[i].selected){
               vendorcode = $("#vendorcode ").get(0).options[i].value;
           }
       }
       var rows = $('#tMmPrList').datagrid('getSelections');
       if(vendorcode==""){
           alert("供应商不能为空");
       }else {
           if(rows.length <= 0){
               alert("请选择采购申请");
           }else {
               if (rows.length > 0) {
                   for (var i = 0; i < rows.length; i++) {
                       var url = "tMmPrController.do?dopc";
                       var formData = new Object();

                       formData['vendorcode'] = vendorcode;
                       formData['id'] = rows[i].id;
                       $.ajax({
                           async: false,
                           cache: false,
                           type: 'POST',
                           data: formData,
                           url: url,// 请求的action路径
                           error: function () {// 请求失败处理函数
                           },
                           success: function (data) {
                               var d = $.parseJSON(data);
                               if (d.success) {

                               }
                           }
                       });
                   }
                   tip("分配成功");
                   $('#tMmPrList').datagrid('reload', {});
               }
           }
       }
   }

 function zdALLSelect() {

     var rows = $('#tMmPrList').datagrid('getSelections');
     var ids = [];
         if(rows.length <= 0){
             alert("请选择采购申请");
         }else {
             if (rows.length > 0) {
                 for (var i = 0; i < rows.length; i++) {
                         ids.push(rows[i].id);
                  }
                     var url = "tMmPrController.do?doBatchzd";
                     var formData = new Object();
                     formData['ids'] = ids.join(',');
                     $.ajax({
                         async: false,
                         cache: false,
                         type: 'POST',
                         data: formData,
                         url: url,// 请求的action路径
                         error: function () {// 请求失败处理函数
                         },
                         success: function (data) {
                             var d = $.parseJSON(data);
                             if (d.success) {

                             }
                         }
                     });
                 }
                 tip("转单成功");
                 $('#tMmPrList').datagrid('reload', {});
             }

 }


 //导入
function ImportXls() {
	openuploadwin('Excel导入', 'tMmPrController.do?upload', "tMmPrList");
}

//导出
function ExportXls() {
	JeecgExcelExport("tMmPrController.do?exportXls","tMmPrList");
}

//模板下载
function ExportXlsByT() {
	JeecgExcelExport("tMmPrController.do?exportXlsByT","tMmPrList");
}

 </script>